<?php

/**
 * 
 * 类 OP_View_Helper_Url2 Helper for making easy links and getting urls that depend on the routes and router
 * 
 * @uses Zend_View_Helper_Abstract
 * @package package_name
 * @author Dengwei
 * @version $Id: Url2.php 32 2011-07-06 06:29:45Z dengwei.cs@gmail.com $
 *
 */
class OP_View_Helper_Url2 extends Zend_View_Helper_Abstract
{

    /**
     * Generates an url given the name of a route.
     *
     * @access public
     *
     * @param  array $urlOptions Options passed to the assemble method of the Route object.
     * @return string Url for the link href attribute.
     */
    public function url2(array $urlOptions = array(), $name = null)
    {
        $front = Zend_Controller_Front::getInstance();
        $request = $front->getRequest();
        $router = $front->getRouter();
        $urlOptions['module'] = isset($urlOptions['module']) ? $urlOptions['module'] : $request->getModuleName();
        $urlOptions['controller'] = isset($urlOptions['controller']) ? $urlOptions['controller'] : $request->getControllerName();
        $urlOptions['action'] = isset($urlOptions['action']) ? $urlOptions['action'] : $request->getActionName();
        
        return $this->view->serverUrl($router->assemble($urlOptions, $name, true, true));
    }
}

?>